package cn.zcy.springboot_web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * bean 用来告诉springfox 怎么去生成swagger所需的规范数据
     */
    @Bean
    public Docket creatRestApi(){

        return new Docket(DocumentationType.SWAGGER_2) //生成Swagger2规范文档
                .pathMapping("/")//设置那些接口会映射到Swagger文档中
                .select()// 接口选择器
                //告诉springFox那些接口需要生成Swagger接口文档
                .apis(RequestHandlerSelectors.basePackage("cn.zcy.springboot_web.controller"))
                //设置那些接口生成在Swagger文档上 any所有的
                .paths(PathSelectors.any())
                //描述文档的主体信息
                .build().apiInfo(new ApiInfoBuilder()
                        .title("springBoot整合Swagger")
                .description("SpringBoot整合Swagger,详细信息.....")
                .version("1.0")
                .contact(new Contact("重阳","cn.zcy","516021118@qq.com"))
                .build());


    }
}
